#include<iostream>
using namespace std;
#define MAXSIZE 100
#define OK 1
#define ERROR 0
#define OVERFLOW -2
typedef int Status;
typedef int ElemType;
int m; //m为操作次数
typedef struct
{ 
    ElemType *elem;
    int length;
}SqList;//顺序表

Status InitList_Sq(SqList &L){
    L.elem = new ElemType[MAXSIZE];  // 分配数组空间
    if(!L.elem) return OVERFLOW;     // 存储分配失败
    L.length = 0;                    // 空表长度为0
    return OK;
}

Status GetElem(SqList L, int i, ElemType &e){
    if(i < 1 || i > L.length)        // 判断i值是否合理
        return ERROR;
    e = L.elem[i-1];                 // 第i-1个单元存储着第i个数据
    return OK;
}

int LocateElem_Sq(SqList L, ElemType e){
    for(int i = 0; i < L.length; i++){
        if(L.elem[i] == e)
            return i+1;              // 返回位置（从1开始）
    }
    return 0;                        // 查找失败
}

Status ListInsert_Sq(SqList &L, int i, ElemType e){
    if(i < 1 || i > L.length + 1)    // i值不合法
        return ERROR;
    if(L.length == MAXSIZE)          // 存储空间已满
        return ERROR;
    
    for(int j = L.length - 1; j >= i - 1; j--)
        L.elem[j+1] = L.elem[j];     // 插入位置及之后的元素后移
    
    L.elem[i-1] = e;                 // 将新元素e放入第i个位置
    L.length++;                      // 表长增1
    return OK;
}

Status ListDelete_Sq(SqList &L, int i){
    if(i < 1 || i > L.length)        // i值不合法
        return ERROR;
    
    for(int j = i; j <= L.length - 1; j++)
        L.elem[j-1] = L.elem[j];     // 被删除元素之后的元素前移
    
    L.length--;                      // 表长减1
    return OK;
}

void Out_list(SqList L){//输出顺序表
    for(int i = 0; i < L.length; i++)
        cout << L.elem[i] << ' ';
    cout << endl;
}

int main() {
    SqList L;
    ElemType e;
    int i, temp, k;

    cin >> m;     //m次操作
    while(m--) {
        char op;
        cin >> op;
        switch(op){
            case 'I'://初始化
                InitList_Sq(L);
                cin >> L.length;
                for(k = 0; k < L.length; k++)
                    cin >> L.elem[k];
                Out_list(L);
                break;
            case 'G'://取元素
                cin >> i;
                temp = GetElem(L, i, e);
                if(temp != 0){
                    cout << e << endl;
                } else {
                    cout << "GET FAIL" << endl;
                }
                break;
            case 'S'://查找元素
                cin >> e;
                temp = LocateElem_Sq(L, e);
                if(temp != 0) {
                    cout << temp << endl;  // 输出位置
                } else {
                    cout << "NOT FOUND" << endl;
                }
                break;
            case 'L'://插入元素
                cin >> i;
                cin >> e;
                temp = ListInsert_Sq(L, i, e);
                if(temp != 0){
                    Out_list(L);
                } else {
                    cout << "INSERT FAIL" << endl;
                }
                break;
            case 'D'://删除元素
                cin >> i;
                temp = ListDelete_Sq(L, i);
                if(temp != 0){
                    Out_list(L);
                } else {
                    cout << "DELETE FAIL" << endl;
                }
                break;
        }
    }
    return 0;
}